/**
 * @author wyvonj
 * @date 2019-07-04
 * @description 接口
 */

import http from './config';
import Axios, { AxiosPromise, AxiosRequestConfig } from 'axios';
import { Response, SecurityPrincipalVo, AuthorityInfoVo, VerificationCodeVo, CustomUserLoginInfo, TaskInfo, ReqTaskInfo, PageVo, RespTaskInfo, ReqTaskOrder, RespTaskOrder, ReqUserInfo, RespUserInfo, UserInfo, ReqProfitIncome, ProfitIncome, RequestPageVo, SysUserGroup, UserPowerVo, AddUserVo, SetUpVo, RespFileVo, RespProfitIncome, CheckCommon, ShopInfo, SysConfig, ProfitLogRequest, ProfitLog, ReqBlacklistInfo, BlacklistInfo, DataStatistics, ReqDataStatistics, ReqOperationLog, OperationLog, ReqSlideshow, Slideshow } from './bean';

class Login {
  public static handleLogin = {
    p: 'userLogin/login',
    r: (params: SecurityPrincipalVo): AxiosPromise<Response<AuthorityInfoVo>> => {
      return http.post(`userLogin/login`, params);
    },
  };
  
  public static handleLogout = {
    p: 'userLogin/quitLonin',
    r: (params: {
      ticket: string
    }): AxiosPromise<Response<any>> => {
      return http.post(`userLogin/quitLonin`, params);
    },
  };
  
  public static handleRegister = {
    p: 'userLogin/saveUser',
    r: (params: any): AxiosPromise<Response<any>> => {
      return http.post(`userLogin/saveUser`, params);
    },
  };
}

class Todo {

  public static getTaskList = {
    p: 'task/taskList',
    r: (params: ReqTaskInfo): AxiosPromise<Response<PageVo<RespTaskInfo>>> => {
      return http.post(`task/taskList`, params);
    },
  };

  /**
   * 获取详情task 不含有 对应的订单信息
   */
  public static getSingleTask = {
    p: 'task/getSingleTask/{taskId}',
    r: (params: {
      taskId: number
    }): AxiosPromise<Response<TaskInfo>> => {
      return http.post(`task/getSingleTask/${params.taskId}`, params);
    },
  };

  /**
   * 获取详情task 不含有 对应的订单信息 
   */
  public static getSingleDetailsTask = {
    p: 'task/getSingleDetailsTask/{taskId}',
    r: (params: {
      taskId: number
    }): AxiosPromise<Response<RespTaskInfo>> => {
      return http.post(`task/getSingleDetailsTask/${params.taskId}`, params);
    },
  };

  /**
   * 获取详情task含有对应的订单信息
   */
  public static getDetailsTaskContainOrder = {
    p: 'task/getDetailsTaskContainOrder/{taskId}',
    r: (params: {
      taskId: number
    }): AxiosPromise<Response<RespTaskInfo>> => {
      return http.post(`task/getDetailsTaskContainOrder/${params.taskId}`);
    },
  };


  /**
   * 重新发布任务
   */
  public static republishTask = {
    p: 'task/publish/{taskId}',
    r: (params: {
      taskId: number
    }): AxiosPromise<Response<any>> => {
      return http.post(`task/publish/${params.taskId}`, params);
    },
  };

  /**
   * 取消发布任务
   */
  public static cancelPublish = {
    p: 'task/cancelPublish/{taskId}',
    r: (params: {
      taskId: number
    }): AxiosPromise<Response<any>> => {
      return http.post(`task/cancelPublish/${params.taskId}`, params);
    },
  };

  /**
   * 完成任务
   */
  public static accomplishTask = {
    p: 'task/accomplish/{taskId}',
    r: (params: {
      taskId: number
    }): AxiosPromise<Response<any>> => {
      return http.post(`task/accomplish/${params.taskId}`, params);
    },
  };

  /**
   * 保存任务（修改）
   */
  public static saveTask = {
    p: 'taskOrder/saveTask',
    r: (params: TaskInfo): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/saveTask`, params);
    },
  };

  /**
   * 订单列表
   */
  public static getOrderList = {
    p: 'taskOrder/taskOrderList',
    r: (params: ReqTaskOrder): AxiosPromise<Response<PageVo<RespTaskOrder>>> => {
      return http.post(`taskOrder/taskOrderList`, params);
    },
  };

  /**
   * 查看订单详情
   */
  public static getOrderDetail = {
    p: 'taskOrder/particulars/{orderId}',
    r: (params: {
      orderId: number,
    }): AxiosPromise<Response<RespTaskOrder>> => {
      return http.post(`taskOrder/particulars/${params.orderId}`);
    },
  };

  /**
   * 抢单接口
   */
  public static competeOrder = {
    p: 'taskOrder/saveTaskOrder/{taskId}',
    r: (params: {
      taskId: number,
    }): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/saveTaskOrder/${params.taskId}`, params);
    },
  };


  /**
   * 作废
   */
  public static invalidOrder = {
    p: 'taskOrder/invalid/{orderId}',
    r: (params: {
      orderId: number,
    }): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/invalid/${params.orderId}`);
    },
  };

  /**
   * 支付订单
   */
  public static payOrder = {
    p: 'taskOrder/payment/{orderId}',
    r: (params: any): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/payment/${params.orderId}`);
    },
  };


  /**
   * 下订单
   */
  public static placeOrder = {
    p: 'taskOrder/savePlaceOrder',
    r: (params: ReqTaskOrder): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/savePlaceOrder`, params);
    },
  };

  /**
   * 完成订单
   */
  public static accomplishOrder = {
    p: 'taskOrder/accomplish/{orderId}',
    r: (params: any): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/accomplish/${params.orderId}`, params);
    },
  };

  /**
   * 确认订单
   */
  public static confirmOrder = {
    p: 'taskOrder/notarizeOrder/{orderId}',
    r: (params: {
      orderId: number,
    }): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/notarizeOrder/${params.orderId}`, params);
    },
  };

  /**
   * 保存评价
   */
  public static saveReview = {
    p: 'taskOrder/saveEvaluate',
    r: (params: ReqTaskOrder): AxiosPromise<Response<any>> => {
      return http.post(`taskOrder/saveEvaluate`, params);
    },
  };


  /**
   * 保存审核条目
   */
  public static saveAudit = {
    p: 'checkCommon/save',
    r: (params: CheckCommon): AxiosPromise<Response<any>> => {
      return http.post(`checkCommon/save`, params);
    },
  };

  /**
   * 获取审核信息
   */
  public static getAuditInfo = {
    p: 'checkCommon/getCheckParticulars',
    r: (params: CheckCommon): AxiosPromise<Response<CheckCommon>> => {
      return http.post(`checkCommon/getCheckParticulars`, params);
    },
  };

  /**
   * 买家
   */
  public static getBuyerList = {
    p: 'user/userList',
    r: (params: ReqUserInfo): AxiosPromise<Response<PageVo<RespUserInfo>>> => {
      return http.post(`user/userList`, params);
    },
  };

  /**
   * 获取单条用户列表
   */
  public static getUserList = {
    p: 'user/UserInfoList',
    r: (params: ReqUserInfo): AxiosPromise<Response<PageVo<RespUserInfo>>> => {
      return http.post(`user/UserInfoList`, params);
    },
  };

  /**
   * 流水明细
   */
   /**
    * 我的账单
    */
  public static getMyBill = {
    p: 'pofitIncome/myBill',
    r: (params: ReqProfitIncome): AxiosPromise<Response<PageVo<ProfitIncome>>> => {
      return http.post(`pofitIncome/myBill`, params);
    },
  };

  /**
   * 保存
   */
  public static saveProfitIncome = {
    p: 'pofitIncome/save',
    r: (params: ProfitIncome): AxiosPromise<Response<any>> => {
      return http.post(`pofitIncome/save`, params);
    },
  };

  /**
   * 流水明细列表
   */
  public static getProfitIncomeList = {
    p: 'pofitIncome/getPofitIncomeList',
    r: (params: ReqProfitIncome): AxiosPromise<Response<PageVo<RespProfitIncome>>> => {
      return http.post(`pofitIncome/getPofitIncomeList`, params);
    },
  };

    /**
   * 获取账单资金详情
   */
  public static getProfitLogList = {
    p: 'profitLog/getProfitLogList',
    r: (params: ProfitLogRequest): AxiosPromise<Response<PageVo<ProfitLog>>> => {
      return http.post(`profitLog/getProfitLogList`, params);
    },
  };


  /**
   * 流水明细
   */
  public static getProfitIncomeDetail = {
    p: 'pofitIncome/getProfitIncomeParticulars/{incomeId}',
    r: (params: {
      incomeId: number,
    }): AxiosPromise<Response<RespProfitIncome>> => {
      return http.post(`pofitIncome/getProfitIncomeParticulars/${params.incomeId}`, params);
    },
  };

  /**
   * 获取店铺列表
   */
  public static getShopList = {
    p: 'shopInfo/getShopInfoUser',
    r: (params: any): AxiosPromise<Response<PageVo<ShopInfo>>> => {
      return http.post(`/shopInfo/getShopInfoUser`, params);
    },
  };

  /**
   * 添加店铺
   */
  public static addShop = {
    p: 'shopInfo/save',
    r: (params: ShopInfo): AxiosPromise<Response<any>> => {
      return http.post(`/shopInfo/save`, params);
    },
  };

  

  /**
   * 获取单条店铺信息
   */
  public static deleteShop = {
    p: 'shopInfo/save',
    r: (params: ShopInfo): AxiosPromise<Response<any>> => {
      return http.post(`/shopInfo/save`, params);
    },
  };


  /**
   * 获取店铺详情
   */
  public static getSingleShop = {
    p: 'shopInfo/getShopParticulars/{shopId}',
    r: (params: ShopInfo): AxiosPromise<Response<any>> => {
      return http.post(`/shopInfo/getShopParticulars/${params.shopId}`, params);
    },
  };



}

class Content {
  /**
   * 获取轮播图列表
   */
  public static getSlideshowList = {
    p: 'slideshow/getSlideshowList',
    r: (params: ReqSlideshow): AxiosPromise<Response<PageVo<Slideshow>>> => {
      return http.post(`slideshow/getSlideshowList`, params);
    },
  };

  /**
   * 保存
   */
  public static saveSlideShowImage = {
    p: 'slideshow/save',
    r: (params: Slideshow): AxiosPromise<Response<any>> => {
      return http.post(`slideshow/save`, params);
    },
  };
  /**
   * 删除图片
   */
  public static deleteSlideShowImage = {
    p: 'slideshow/delete/{sId}',
    r: (params: {
      sId: any
    }): AxiosPromise<Response<any>> => {
      return http.post(`slideshow/delete/${params.sId}`, params);
    },
  };

}

class User {

  /**
   * 买家列表
   */
  public static getUserList = {
    p: 'user/userList',
    r: (params: ReqUserInfo): AxiosPromise<Response<PageVo<RespUserInfo>>> => {
      return http.post(`user/userList`, params);
    },
  };

  /**
   * 用户列表
   */
  public static getUserInfoList = {
    p: 'user/UserInfoList',
    r: (params: ReqUserInfo): AxiosPromise<Response<PageVo<RespUserInfo>>> => {
      return http.post(`user/UserInfoList`, params);
    },
  };

  /**
   * 获取单条用户信息
   */
  public static getSingleUserInfo = {
    p: 'user/singleUserInfo/{userId}',
    r: (params: {
      userId: number,
    }): AxiosPromise<Response<RespUserInfo>> => {
      return http.post(`user/singleUserInfo/${params.userId}`, params);
    },
  };

}

class System {

  /**
   * 获取系统参数
   */
  public static getSysSettinglist = {
    p: 'sysConfig/getSysSetlist',
    r: (params: SysConfig): AxiosPromise<Response<Array<SysConfig>>> => {
      return http.post(`sysConfig/getSysSetlist`, params);
    },
  };


  /**
   * 获取单个系统参数
   */
  public static getSysSetting = {
    p: 'sysConfig/getSysSet',
    r: (params: {
      confName: string,
    }): AxiosPromise<Response<SysConfig>> => {
      return http.post(`sysConfig/getSysSet`, params);
    },
  };

  /**
   * 获取系统参数
   */
  public static saveSystemSetting = {
    p: 'sysConfig/save',
    r: (params: SysConfig): AxiosPromise<Response<any>> => {
      return http.post(`sysConfig/save`, params);
    },
  };

  /**
   * 修改汇率
   */
  public static updateExchange = {
    p: 'sysConfig/updateExchange',
    r: (params: SysConfig): AxiosPromise<Response<any>> => {
      return http.post(`sysConfig/updateExchange`, params);
    },
  };

  /**
   * 修改佣金比例
   */
  public static updateCommision = {
    p: 'sysConfig/updateCommission',
    r: (params: Array<SysConfig>): AxiosPromise<Response<any>> => {
      return http.post(`sysConfig/updateCommission`, params);
    },
  };

  /**
   * 获取黑名单
   */
  public static getBlackList = {
    p: 'blacklistInfo/getBlacklistInfoList',
    r: (params: ReqBlacklistInfo): AxiosPromise<Response<PageVo<BlacklistInfo>>> => {
      return http.post(`blacklistInfo/getBlacklistInfoList`, params);
    },
  };

  /**
   * 获取黑名单
   */
  public static saveBlackUser = {
    p: 'blacklistInfo/save',
    r: (params: ReqBlacklistInfo): AxiosPromise<Response<PageVo<BlacklistInfo>>> => {
      return http.post(`blacklistInfo/save`, params);
    },
  };

  /**
   * 获取数据统计
   */
  public static getDataStatistics = {
    p: 'dataStatistics/getDataStatisticsd',
    r: (params: ReqDataStatistics): AxiosPromise<Response<PageVo<DataStatistics>>> => {
      return http.post(`dataStatistics/getDataStatisticsd`, params);
    },
  };

  /**
   * 刷新数据统计
   */
  public static refreshDataStatistics = {
    p: 'dataStatistics/refresh',
    r: (params: ReqDataStatistics): AxiosPromise<Response<boolean>> => {
      return http.post(`dataStatistics/refresh`, params);
    },
  };

  /**
   * 获取日志
   */
  public static getLog = {
    p: 'operationLog/operationLogList',
    r: (params: ReqOperationLog): AxiosPromise<Response<PageVo<OperationLog>>> => {
      return http.post(`operationLog/operationLogList`, params);
    },
  };

}

class Admin {


  /**
   * 查询用户组list
   */
  public static getGroupList = {
    p: 'power/grouplist',
    r: (params: RequestPageVo): AxiosPromise<Response<PageVo<SysUserGroup>>> => {
      return http.post(`power/grouplist`, params);
    },
  };

  /**
   * 查询用户list
   */
  public static getUserList = {
    p: 'power/userlist',
    r: (params: RequestPageVo): AxiosPromise<Response<PageVo<UserPowerVo>>> => {
      return http.post(`power/userlist`, params);
    },
  };

  /**
   * 添加用户
   */
  public static addUser = {
    p: 'power/addUser',
    r: (params: AddUserVo): AxiosPromise<Response<any>> => {
      return http.post(`power/addUser`, params);
    },
  };

  /**
   * 添加角色
   */
  public static addRole = {
    p: 'power/addgroup',
    r: (params: SysUserGroup): AxiosPromise<Response<any>> => {
      return http.post(`power/addgroup`, params);
    },
  };

  /**
   * 编辑用户
   */
  public static modifyUser = {
    p: 'power/editoruser',
    r: (params: SysUserGroup): AxiosPromise<Response<any>> => {
      return http.post(`power/editoruser`, params);
    },
  };

  /**
   * 删除用户
   */
  public static deleteUser = {
    p: 'power/user/{userId}',
    r: (params: {
      userId: number,
    }): AxiosPromise<Response<any>> => {
      return http.post(`power/user/${params.userId}`);
    },
  };

  /**
   * 设置角色权限
   */
  public static setRoleAuthority = {
    p: 'power/setup',
    r: (params: SetUpVo): AxiosPromise<Response<any>> => {
      return http.post(`power/setup`, params);
    },
  };

  /**
   * 修改用户自己的密码
   */
  public static setUserPassword = {
    p: 'power/password',
    r: (params: {
      password: string,
    }): AxiosPromise<Response<any>> => {
      return http.post(`power/password`, params);
    },
  };

  /**
   * 根据groupId查询权限
   */
  public static queryRoleAuthority = {
    p: 'power/info',
    r: (params: SysUserGroup): AxiosPromise<Response<any>> => {
      return http.post(`power/info`, params);
    },
  };

  /**
   * 获取权限菜单列表
   * @param sysGroup 1后台服务，0卖家服务 
   */
  public static getMenuList = {
    p: 'power/detail/{sysGroup}',
    r: (params: {
      sysGroup: any
    }): AxiosPromise<Response<any>> => {
      return http.get(`power/detail/${params.sysGroup}`);
    },
  };

}


class FileHandler {
  public static uploadFile = {
    p: 'file/upload',
    r: (params: FormData, config: AxiosRequestConfig): AxiosPromise<Response<Array<RespFileVo>>> => {
      return http.post(`/file/upload`, params, config);
    },
  };
}

export {
  Login,
  Todo,
  Content,
  User,
  System,
  Admin,
  FileHandler,
};